package com.joshua.web.dao;

import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;

import com.joshua.web.model.Product;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/applicationContext.xml" })
@Transactional
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
public class testProductDao {

    private ProductDao productDao;

    @Autowired
    public void setDBColumnDao(ProductDao productDao) {
        this.productDao = productDao;
    }

    @Test
    public void testFindAll() {
    	List<Product> products = productDao.findAll();

    	System.out.println(products.size());
    }
    
    
    @Test
    public void testFindOne() {
    	Product product = productDao.findOne(28l);
    	
    	System.out.println(product.getCode());
    }

    @Test
    public void testDeleteOne() {
    	productDao.deleteOne(28l);
    	
    }

}
